<template>
    <div class="row">
        <el-checkbox v-model="comp.enabled">{{ comp.__classname__ }}</el-checkbox>
        <el-button round size="small" :icon="Document" @click="gm.toConsole(comp)"></el-button>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>ContentSize</el-text>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="Model.width">
            <template #suffix>
                <span>W</span>
            </template>
        </el-input-number>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="Model.height">
            <template #suffix>
                <span>H</span>
            </template>
        </el-input-number>
    </div>

    <div class="row-start">
        <el-text class="span-title" truncated>AnchorPoint</el-text>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="comp.anchorX">
            <template #suffix>
                <span>X</span>
            </template>
        </el-input-number>
        <el-input-number size="small" :controls="false" :step="0.1" v-model="comp.anchorY">
            <template #suffix>
                <span>Y</span>
            </template>
        </el-input-number>
    </div>
</template>

<script lang="ts" setup>
import { Document } from '@element-plus/icons-vue'
import gm from './gm'

const props = defineProps<{
    comp: CCComponent,
    update: Number,
}>()

class Model {
    static get comp() {
        return props.comp
    }

    static get width(){
        return this.comp.contentSize.width
    }

    static set width(value: number) {
        const ori = this.comp.contentSize
        this.comp.setContentSize(value, ori.height)
    }

    static get height() {
        return this.comp.contentSize.height
    }

    static set height(value: number) {
        const ori = this.comp.contentSize
        this.comp.setContentSize(ori.width, value)
    }
}
</script>